#include<iostream>
#include<vector>
using namespace std;
vector<int> productExceptSelf(vector<int>& nums) {
    int size = nums.size();
    vector<int> answer(size), f(size), g(size);
    f[0] = g[size - 1] = 1;
    for (int i = 1; i < size; i++)
        f[i] = f[i - 1] * nums[i - 1];
    for (int i = size - 2; i >= 0; i--)
        g[i] = g[i + 1] * nums[i + 1];
    for (int i = 0; i < size - 1; i++)
        answer[i] = g[i] * f[i];
    return answer;
}
int pivotIndex(vector<int>& nums) {
    int size = nums.size();
    vector<int> dp1(size), dp2(size);
    for (int x = 1; x < nums.size(); x++)
        dp1[x] = dp1[x - 1] + nums[x - 1];
    for (int y = size - 2; y >= 0; y--)
        dp2[y] = dp2[y + 1] + nums[y + 1];
    for (int z = 0; z < size; z++)
        if (dp1[z] == dp2[z])
            return z;
    return -1;
}
int main()
{
    vector<int> v{ 1, 2, 3, 4 };
    productExceptSelf(v);
    return 0;
}
